﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessComponents;
using WaterfrontLodge.Validators;
using BusinessComponents.Managers;

namespace WaterfrontLodge.WebForms.RoomTypeMgt
{
    public partial class RoomTypeAdd1 : RoomTypeAddController
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                reset();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string rmDesc = txtDescription.Text;
            string rmSize = txtRoomSize.Text;
            string rmOccup = txtMaxOccupant.Text;
            string rmPrice = txtStdPrice.Text;

            bool retRoomType = ManagerFactory.RoomTypeMgr.CheckDuplicateRoomType(txtDescription.Text);
            if (retRoomType)
            {
                lblMsg.Text = "The Room Type Description is already existed!";
            }
            else
            {
                lblMsg.Text = "";

                RoomType rt = getRoomTypeTransferObject();
                rt.Description = rmDesc;
                rt.RoomSize = rmSize;
                rt.MaxOccupant = Convert.ToInt32(rmOccup);
                rt.StdPrice = Convert.ToInt32(rmPrice) * 100;

                Response.Redirect(getNextView());
            }
            
        }

        override
        protected string getCurView()
        {
            return "RoomTypeAdd1";
        }
    }
}